<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/8/9
  Time: 14:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"  pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" charset="utf-8" />
    <title>用户中心 - 嗨购</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/static/img/higou.png" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/headz.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">

        #body {
            width: 100%;
            height: 800px;
            background-color:#ede7e1;
            padding-top: 20px;

        }
        #kid {
            width: 960px;
            height: 700px;
            background-color: white;
            margin: 0 auto;
            padding-top: 10px;
            padding-left: 10px;
            /*overflow: hidden;*/
        }
        #kid_left{
            width: 148px;
            height: 700px;
            border-right:1px dotted lightgray ;
            display: inline-block;
            float: left;
        }
        #tou {
            width: 160px;
            height: 111px;
            position: absolute;
        }

        #tou>div {
            display: inline-block;
            vertical-align: top;
        }

        .xinx {
            text-indent: 5px;
        }

        #yh {
            color: red;
            margin-bottom: 10px;
        }

        .centerLeft {
            width: 160px;
            display: inline-block;
            position: absolute;
            top: 130px;
            margin-left: -12px;
            box-sizing: border-box;
            margin-top: 200px;
        }
        /*.zi .dingdan a{*/
             /*color: #e4393c;*/
             /*background-color: white;*/
            /*}*/

        .shang {
            width: 100%;
            height: 184px;
        }
        .shang2{
            width: 100%;
            height: 137px;
            margin-top: -49px;
        }
        .title {
            width: 100%;
            height: 41px;
            background: lightgrey;
            color: #333;
            font-size: 18px;
            line-height: 41px;
            vertical-align: middle;
        }
        .zi{
            display: inline-block;
            vertical-align: top;
        }
        .shang>ul {
            width: 159px;
            height: 141px;
        }
        .shang2>ul {
            width: 159px;
            height: 141px;
        }
        .shang>ul>li {
            width: 159px;
            height: 46.8px;
            background-color: #ede7e1;
            border-bottom: 1px solid lightgray;
            border-left: 1px solid lightgray;
        }
        .shang2>ul>li {
            width: 159px;
            height: 46.8px;
            background-color: #ede7e1;
            border-bottom: 1px solid lightgray;
            border-left: 1px solid lightgray;
        }
        .shang>ul a {
            display: inline-block;
            width: 100%;
            height: 100%;
            color: #666;
            line-height: 46.8px;
            text-align: center;
            text-decoration: none;
        }
        .shang2>ul a {
            display: inline-block;
            width: 100%;
            height: 100%;
            color: #666;
            line-height: 46.8px;
            text-align: center;
            text-decoration: none;
        }
        .kid_right{
            box-sizing: border-box;
            width: 802px;
            height: 800px;
            display: inline-block;
            float: left;
        }
        .kid_right > div {
            display: none;
        }
        .kid_right > div.dingdan {
            display: block;
        }

        .right_top{
            width: 796px;
            height: 46px;
            line-height: 46px;
            border-bottom: 1px solid #dbd6d0;
            font-weight: 400;
            position: relative;
            padding-left: 15px;
            overflow: hidden;
            font-size: 18px;
            display: block;
            color: #333;
        }
        .shu>input{
            width: 122px;
            height: 41px;
            line-height: 41px;
            border-radius: 3px 3px 0 0;
            background-color: #f8f6f4;
            border: 1px solid #dbd6d0;
            border-bottom: 0;
            text-decoration: none;
            padding: 0 20px;
            color: #666;
            float: left;
            margin-right: -1px;
            margin-top: 17px;
            text-align: center;
        }

        #imgBox>#imgBox3,#imgBox>#imgBox4{
            display: flex;
            flex-wrap: wrap;
            overflow: auto;
        }
        #imgBox>#imgBox4{
            display: none;
        }
        .z{
            margin-left: 15px;
        }
        .xian{
            width: 769px;
            height: 150px;
            border: 1px solid #DBD6D0;
            margin-top: 58px;
            /*text-align: center;*/
            padding: 200px 0;
            margin-left: 15px;
        }
        #ttt{
            width: 50%;
            text-align:center;
            margin-left: 130px;
            margin-top: 20px;
        }
        #tttt{
            width: 100%;
            text-align:center;
            margin-top: -180px;
        }
        #tt{
            width: 80%;
            height: 180px;
            text-align:center;
            margin-left: 50px;
            margin-top: 20px;
            overflow:scroll;

        }
        #ttttt{
            width: 100%;
            text-align:center;
            margin-top: -180px;
        }
        #container-luck-lottery>table{
            width: 300px;
            height: 400px;
            color: #666;
            font-size: 12px;
            margin-top: 50px;
            margin-left: 100px;
            outline: none;
        }

        input:focus{
            outline: none;
            box-shadow: none;
        }
        #container-password>table{
            width: 300px;
            height: 300px;
            color: #666;
            font-size: 12px;
            margin-top: 50px;
            margin-left: 100px;
            outline: none;
        }

        #container-password>tr{
            margin-top: 15px;
        }
        .address{
            width: 755px;
            height: 24px;
            line-height: 24px;
            color: #666;
            font-size: 16px;
            font-weight: 700;
            text-indent: 20px;
            margin-top: 30px;

        }
        #container-dizhi>.xinz{
            width: 480px;
            height: 300px;
            color: #666;
            font-size: 12px;
            margin-top: 30px;
            margin-left: 100px;
            outline: none;
        }
        #container-dizhi>tr{
            margin-top: 15px;
        }
        #container-dizhi>#cun{
            width: 750px;
            text-align: center;
            margin-left: 20px;
            margin-top: 20px;
        }
        #form1{
            margin-top: 100px;
            margin-left: 100px;
        }
        #form1 tr{
            margin-top: 20px;
        }
        .money>table{
            width: 600px;
            text-align: center;
            margin-left: 80px;
            margin-top: 20px;
        }
        .mid_top_head{
            margin-top: -10px;

        }
        .mid_top_head a{
            color: #6C6C6C;
        }
        #pop{width:300px;height:250px;border:solid 1px #000;position:fixed;left:50%;top:50%;margin-left:-150px;margin-top:-200px;border:solid 1px #000;border-radius:5px;background:#fff;display:none;z-index:22}
        #lightbox{width:100%;height:100%;position:fixed;top:0;left:0;background:#000;filter:alpha(opacity=50);opacity:.5;display:none;}
        #popp{width:600px;height:250px;border:solid 1px #000;position:fixed;left:50%;top:50%;margin-left:-250px;margin-top:-200px;border:solid 1px #000;border-radius:5px;background:#fff;display:none;z-index:22}
        #lightboxx{width:100%;height:100%;position:fixed;top:0;left:0;background:#000;filter:alpha(opacity=50);opacity:.5;display:none;}

    </style>
</head>

<body>
<div class="head">
    <div class="head_top">
        <div class="head_top_mid mid_top_head" >
            <ul class="head_ul head_ul_left">
                <c:if test="${not empty sessionScope.user}">
                    <li>欢迎 [${sessionScope.user.u_name}] 来到嗨购! <a onclick="window.location = 'exit.jsp' "href="#">[退出]</a></li>
                </c:if>
                <c:if test="${empty sessionScope.user}">
                    <li>欢迎来到嗨购!</li>
                    <li>
                        <a href="login.jsp">请登录</a>
                    </li>
                    <li>
                        <a href="register.jsp">快速注册</a>
                    </li>
                </c:if>
            </ul>
            <ul class="head_ul head_ul_right">
                <li>
                    <a href="#"><span class="img1"></span>收藏品牌</a>
                </li>
                <li>
                    <a href="#">我的嗨购</a>
                </li>
                <li>正品保证</li>
            </ul>
        </div>
    </div>
    <div class="head_center">
        <a onclick="window.location = 'index.jsp' "href="#"><div class="logo">
        </div></a>
        <div class="cart_box">
            <!-- ${pageContext.request.contextPath}/SearchCarServlet.do -->
            <a onclick="window.location = '${pageContext.request.contextPath}/SearchCarServlet.do' "href="#">
                <div class="cart_box_img">
                    <img src="${pageContext.request.contextPath}/static/img/cart.gif" width="28px" height="28px" />
                </div>
                <span style="">
								去购物车结算
							</span>
            </a>
        </div>
    </div>
    <div class="head_bot">
        <div class="head_bot_mid">
            <div class="head_bot_mid_nav">
                <a onclick="window.location = 'index.jsp' "href="#">首页</a>
            </div>
            <div class="head_bot_mid_nav">
                <a onclick="window.location = 'women.jsp' "href="#">女装</a>
            </div>
            <div class="head_bot_mid_nav">
                <a onclick="window.location = 'men.jsp' "href="#">男装</a>
            </div>
            <div class="head_bot_mid_nav">
                <a onclick="window.location = 'outside.jsp' "href="#">运动户外</a>
            </div>
            <div class="head_bot_mid_nav">
                <a onclick="window.location = 'home.jsp' "href="#">家居用品</a>
            </div>
            <div class="head_bot_mid_nav">
                <a onclick="window.location = 'doctor.jsp' "href="#">医疗保健</a>
            </div>

            <div class="head_bot_right">
                <img src="${pageContext.request.contextPath}/static/img/z_01new.jpg" />
                <img src="${pageContext.request.contextPath}/static/img/z02.jpg" />
                <img src="${pageContext.request.contextPath}/static/img/z03.jpg" />

            </div>
        </div>

    </div>
</div>
<div id="body">
    <div id="kid">
        <div id="kid_left">
            <div id="tou">
                <a href="#" onclick="return PopLayer(this)" ><img src="${pageContext.request.contextPath}/static/img/images/${sessionScope.user.u_img}" alt="头像" width="66px"/></a>
                <div id="xinx">
                    <div id="yh">${sessionScope.user.u_name}</div>
                    <div id="hy">普通会员</div>
                </div>
            </div>
            <div class="centerLeft">
                <div class="shang">
                    <div class="title">
                        <img src="${pageContext.request.contextPath}/static/img/nav.png"  style="margin-left: -8px;"/>
                        <span class="zi">我的嗨购</span>
                    </div>
                    <ul>
                        <li>
                            <a class="#container-myorder" href="">我的订单</a>
                        </li>
                        <li>
                            <a class="#container-money" href="">我的消费</a>
                        </li>
                    </ul>
                </div>
                <div class="shang2">
                    <div class="title">
                        <img src="${pageContext.request.contextPath}/static/img/nav.png"  style="margin-left: -8px;"/>
                        <span class="zi">管理个人账户</span>
                    </div>
                    <ul>

                        <li>
                            <a class="#container-luck-lottery" href="">设置账户信息</a>
                        </li>
                        <li>
                            <a class="#container-password" href="">修改密码</a>
                        </li>
                        <li>
                            <a class="#container-dizhi" href="">管理收货地址</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="kid_right">
            <div class="dingdan" id="container-myorder">
                <div class="right_top">
                    我的订单
                </div>
                <div class="shu">
                    <input class="z" type="button" name="" id="btn3" value="已付款" />
                    <input type="button" name="" id="btn4" value="交易完成" />
                </div>
                <div id="imgBox">
                    <div class="xian" id="imgBox3">
                        <div id="tttt"></div>
                    </div>
                    <div class="xian" id="imgBox4">
                        <div id="ttttt"></div>
                    </div>
                </div>
            </div>

            <div class="money" id="container-money">
                <div class="right_top">
                    我的消费情况
                </div>
                <table class='table table-hover'>
                <tr>
                    <td>时间</td>
                    <td>消费金额</td>
                    </tr>
                    <tbody id="ttt">
                    </tbody>
                </table>
            </div>


            <div id="container-luck-lottery">
                <div class="right_top">
                    设置账户信息
                </div>
                <table>
                    <tr class="form-group">
                        <td>*用户名：</td>
                        <td>
                            <input class="form-control" type="text" name="u_name" id="u_name" />
                        </td>
                        <td><span id="shi"></span></td>
                    </tr>
                    <tr class="form-group">
                        <td>&nbsp;&nbsp;Email：</td>
                        <td>
                            <input class="form-control" type="email" name="u_email" id="u_email" />
                        </td>
                        <td></td>
                    </tr>
                    <tr class="form-group">
                        <td >&nbsp;&nbsp;性别：</td>
                        <td>
                            <input type="radio" name="u_sex" id="boy_01" value="男" checked="checked"/>男&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;&nbsp;<input type="radio" name="u_sex" id="girl" value="女"/>女
                        </td>
                        <td></td>
                    </tr>
                    <tr class="form-group">
                        <td>&nbsp;&nbsp;生日：</td>
                        <td>
                            <input class="form-control" type="text" onclick="WdatePicker()" name="u_birth" id="u_birth" readonly="readonly"/>
                        </td>
                        <td></td>
                    </tr>
                    <tr class="form-group">
                        <td></td>
                        <td>
                            <button type="submit" class="btn btn-danger" id="baocun">保存修改</button>
                        </td>
                        <td></td>
                    </tr>
                </table>
            </div>

            <div id="container-password">
                <div class="right_top">
                    修改密码
                </div>
                <div id="form1">
                <table>
                    <tr class="form-group" >
                        <td>*原密码：</td>
                        <td>
                            <input class="form-control" type="password" name="u_pwd" id="u_pwd"  />
                        </td>
                        <td><span id="ti"></span></td>
                    </tr>
                    <tr class="form-group">
                        <td>*新密码：</td>
                        <td>
                            <input class="form-control" type="password" name="u_pwd1" id="u_pwd1"  />
                        </td>
                        <td></td>
                    </tr>
                    <tr class="form-group">
                        <td>*确认新密码：</td>
                        <td>
                            <input class="form-control" type="password" name="u_pwd2" id="u_pwd2" onkeyup="validate()" />
                        </td>
                        <td><span id="tishi"></span></td>
                    </tr>
                    <tr class="form-group">
                        <td></td>
                        <td>
                            <button type="submit" class="btn btn-danger"  id="submit">确认</button>
                        </td>
                        <td></td>
                    </tr>
                </table>
                </div>
            </div>
            <div id="container-dizhi">
                <div class="right_top">
                    管理收货地址
                </div>
                <div class="address">
                    新增收货地址
                </div>
                    <input type="hidden" id="u_id" name="u_name" value="12">
                <table class="xinz">
                    <tr class="form-group">
                        <td>*收件人姓名：</td>
                        <td>
                            <input class="form-control" type="text" name="a_name" id="a_name" />
                        </td>
                    </tr>
                    <tr>
                        <td>*收货地址:</td>
                        <td>

                            <select name="pro" id="pro" class="sel_p"  onchange="addCity()" onchange="address(1,this)">
                                <option value="0">---请选择---</option>
                            </select>
                            <select name="city" id="city"  class="sel_c"  onchange="address(2,this)">
                                <option value="0">---请选择---</option>
                            </select>
                        </td>
                        <td></td>
                    </tr>
                    <tr class="form-group">
                        <td>*详细地址：</td>
                        <td>
                            <textarea id="a_add" name="a_add" class="form-control" rows="3" cols="50"></textarea>
                        </td>
                    </tr>
                    <tr class="form-group">
                        <td>*手机号码：</td>
                        <td>
                            <input class="form-control" type="number" name="a_tel" id="a_tel" />
                        </td>
                    </tr>
                    <tr class="form-group">
                        <td></td>
                        <td>
                            <button id="didi" type="submit" class="btn btn-danger">保存收货地址</button>
                        </td>
                        <td></td>
                    </tr>
                </table>

                <div class="address">
                    已保存的地址
                </div>
               <div id="tt"></div>
                <div id="lightboxx"></div>
                <div id="popp">
                    <input type="hidden" id="a_id" name="a_id">
                    <table width="100%" border="0" cellpadding="5" cellspacing="5">
                        <tr><th colspan="2">修改收货地址</th>
                            <table class="xinz">
                                <tr class="form-group">
                                    <td>*收件人姓名：</td>
                                    <td>
                                        <input class="form-control" type="text" name="a_name" id="a_namee"  />
                                    </td>
                                </tr>
                                <tr>
                                    <td>*收货地址:</td>
                                    <td>
                                        <select name="pro" id="proo" class="sel_pp"  onchange="addCityy()" onchange="addresss(1,this)">
                                            <option value="0">---请选择---</option>
                                        </select>
                                        <select name="city" id="cityy"  class="sel_cc"  onchange="addresss(2,this)">
                                            <option value="0">---请选择---</option>
                                        </select>
                                    </td>
                                    <td></td>
                                </tr>
                                <tr class="form-group">
                                    <td>*详细地址：</td>
                                    <td>
                                        <textarea id="a_addd" name="a_add" class="form-control"  rows="3" cols="50"></textarea>
                                    </td>
                                </tr>
                                <tr class="form-group">
                                    <td>*手机号码：</td>
                                    <td>
                                        <input class="form-control" type="number" name="a_tel" id="a_tell" />
                                    </td>
                                </tr>
                            </table>
                        <tr><td colspan="2" align="right"><input id="didii" type="submit" value="保存" />　<input type="button" value="关闭" onclick="PoppLayer()" /> </td></tr>
                    </table>

                </div>
            </div>

        </div>
        <div>
            <img src="${pageContext.request.contextPath}/static/img/images/footer_dy.jpg"
                 style="margin-top: -50px; margin-left: -300px;height: 100px;width:1529px"/>
        </div>

        <div id="lightbox"></div>
        <div id="pop">
            <form action="${pageContext.request.contextPath}/TouXiangServlet.do?u_id=${sessionScope.user.u_id}" enctype="multipart/form-data" method="post">
            <table width="100%" border="0" cellpadding="5" cellspacing="5">
                <tr><th colspan="2">上传头像</th></tr>
                <tr><input type="file" name="u_touxiang" id="u_touxiang" /></tr>
                <tr><td colspan="2" align="right"><input type="submit" value="上传" />
                    　<input type="button" value="关闭" onclick="PopLayer()" /> </td></tr>
            </table>
        </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function validate() {
        var pwd1 = document.getElementById("u_pwd1").value;
        var pwd2 = document.getElementById("u_pwd2").value;
        if(pwd1 == pwd2)
        {
            document.getElementById("tishi").innerHTML="<font color='green'>两次密码相同</font>";
            document.getElementById("submit").disabled = false;
        }
        else {
            document.getElementById("tishi").innerHTML="<font color='red'>两次密码不相同</font>";
            document.getElementById("submit").disabled = true;
        }
    }
</script>
<script type="text/javascript">
    $("#u_pwd").blur(function(){
        var p = document.getElementById("u_pwd").value;
        var pwd="${sessionScope.user.U_PWD}";
        if(p == pwd)
        {
            document.getElementById("ti").innerHTML="<font color='green'>与原密码相同</font>";
            document.getElementById("submit").disabled = false;

        }
        else {
            document.getElementById("ti").innerHTML="<font color='red'>与原密码不相同</font>";
            document.getElementById("submit").disabled = true;

        }
    })
</script>

<script type="text/javascript">
    $("#u_name").blur(function(){
        var m= document.getElementById("u_name").value;
        if(!m)
        {
            document.getElementById("shi").innerHTML="<font color='red'>用户名不能为空</font>";
            document.getElementById("baocun").disabled =true;

        }
        else {
            document.getElementById("shi").innerHTML="<font color='green'>用户名合法</font>";
            document.getElementById("baocun").disabled =false;

        }
    })
</script>

<script>
    var pop=document.getElementById('pop'),lightbox=document.getElementById('lightbox')
    function PopLayer(obj) {
        lightbox.style.display = pop.style.display = obj ? 'block' : 'none';
        return true;
    }
</script>
<script>
    var popp=document.getElementById('popp'),lightboxx=document.getElementById('lightboxx');
    function PoppLayer(obj) {
        lightboxx.style.display = popp.style.display = obj ? 'block' : 'none';
        return true;
    }
</script>
<script type="text/javascript">
    $(' a').click(function(e){
        e.preventDefault();
        //修改li的dingdan的位置
        $(this).parent().addClass('dingdan').siblings('.dingdan').removeClass('dingdan');
        //修改右侧主体中的div的dingdan的位置
        var id = $(this).attr('class');
        $(id).addClass('dingdan').siblings('.dingdan').removeClass('dingdan');


        //我的消费
        if(id=="#container-money")
        {
            jQuery.post("${pageContext.request.contextPath}/ShowPayServlet.do",{"u_id":${sessionScope.user.U_ID}},function (data) {
                var tr="";
                jQuery.each(data,function (i,item) {
                    tr+="<tr>";
                    tr+="<td>";
                    var date=new Date(item.O_DATE);
                    tr+=date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.O_PRICE;
                    tr+="</td>";
                    tr+="</tr>";
                });
                jQuery("#ttt").html(tr);
            },"JSON");
        }

        //显示已付款和已完成的订单
        if(id=="#container-myorder")
        {
            jQuery.post("${pageContext.request.contextPath}/PayAndFinishServlet.do",{"u_id":${sessionScope.user.U_ID}},function (data) {
                var tr="";
                tr+="<table class='table table-hover'>";
                tr+="<tr>";
                tr+="<td>时间</td>";
                tr+="<td>收货人姓名</td>";
                tr+="<td>收货人手机号</td>";
                tr+="<td>收货人地址</td>";
                tr+="<td>商品名称</td>";
                tr+="<td>商品数量</td>";
                tr+=" <td>消费金额</td>";
                tr+="</tr>";
                tr+="<tbody>";
                jQuery.each(data,function (i,item) {
                    tr+="<tr>";
                    tr+="<td>";
                    var date=new Date(item.O_DATE);
                    tr+=date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.A_NAME;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.A_TEL;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.A_ADD;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.G_NAME.toString();
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.O_NUM;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.O_PRICE;
                    tr+="</td>";
                    tr+="</tr>";
                });
                tr+="</tbody>";
                tr+=" </table>";
                jQuery("#tttt").html(tr);
                jQuery("#ttttt").html(tr);
            },"JSON");

        }

        //修改用户信息
        if (id=="#container-luck-lottery") {
            jQuery("#baocun"). click(function () {
                var u_name=$("#u_name").val();
                var u_email=$("#u_email").val();
                var u_sex=$("input[name='u_sex']:checked").val();
                var u_birth=$("#u_birth").val();
                        $.ajax({
                            url:"${pageContext.request.contextPath}/EditUserInfoServlet.do",
                            data:{"u_id":${sessionScope.user.U_ID},"u_name":u_name,"u_email":u_email,"u_sex":u_sex,"u_birth":u_birth},
                            type:"post",
                            dataType:"json",
                            success:function(data){
                                alert("保存成功");
                            },
                            error:function(){
                                    alert("保存失败");
                                }
                        });
                }
            )
        }

        // 修改密码
        if (id=="#container-password") {
                jQuery("#submit").click(function () {
                    var u_pwd=$("#u_pwd").val();
                    var u_pwd1=$("#u_pwd1").val();
                    if (u_pwd!=null && u_pwd1!=null){
                        $.ajax({
                            url:"${pageContext.request.contextPath}/EditPwdServlet.do",
                            data:{"u_id":${sessionScope.user.U_ID},"u_pwd":u_pwd,"u_pwd1":u_pwd1},
                            type:"post",
                            dataType:"json",
                            success:function(data){
                                alert("修改成功");
                            },
                            error:function(){
                                alert("修改失败");
                            }
                        });
                    } else {
                    }
                }
                )
        }

        //添加新地址
        if (id=="#container-dizhi") {
            jQuery("#didi"). click(function () {
                    var a_id=$("#a_id").val();
                   // var u_id=$("#u_id").val();
                    var a_add=$("#a_add").val();
                    var a_name=$("#a_name").val();
                    var a_tel=$("#a_tel").val();
                    $.ajax({
                        url:"${pageContext.request.contextPath}/AddAddressServlet.do",
                        data:{"a_id":a_id,"u_id":${sessionScope.user.U_ID},"a_add":a_add,"a_name":a_name,"a_tel":a_tel},
                        type:"post",
                        dataType:"json",
                        success:function(data){
                            alert("添加成功");
                            jQuery.post("${pageContext.request.contextPath}/FindAddressServlet.do",{"u_id":${sessionScope.user.U_ID}},function (data) {
                                var tr="";
                                tr+="<table class='table table-hover'>";
                                tr+="<tr>";
                                tr+="<td>地址编号</td>"
                                tr+="<td>收货人</td>";
                                tr+=" <td>收货地址</td>";
                                tr+=" <td>手机号</td>";
                                tr+=" <td>操作</td>";
                                tr+="</tr>";
                                tr+="<tbody>";
                                jQuery.each(data,function (i,item) {
                                    tr+="<tr>";
                                    tr+="<td>";
                                    tr+=item.A_ID;
                                    tr+="</td>";
                                    tr+="<td>";
                                    tr+=item.A_NAME;
                                    tr+="</td>";
                                    tr+="<td>";
                                    tr+=item.A_ADD;
                                    tr+="</td>";
                                    tr+="<td>";
                                    tr+=item.A_TEL;
                                    tr+="</td>";
                                    tr+="<td>";
                                    tr+="<button type='button' class='btn btn-danger' name='a_id' " +
                                        "onclick=\"return PoppLayer(this,'"+item.A_ID+"','"+item.A_NAME+"','"+item.A_ADD+"','"+item.A_TEL+"')\">修改</button>";
                                    tr+="<button type='button' class='btn btn-danger' name='a_id' onclick='doDelete(this,"+item.A_ID+")'>删除</button>";
                                    tr+="</td>";
                                    tr+="</tr>";
                                });
                                tr+="</tbody>";
                                tr+=" </table>";
                                jQuery("#tt").html(tr);
                            },"JSON");
                        },
                        error:function(){
                            alert("添加失败");
                        }
                    });
                }
            )
        }

        //修改已保存的地址
        if (id=="#container-dizhi") {
            jQuery("#didii"). click(function () {
                    var a_addd=document.getElementById("a_addd").value;
                    var a_namee=document.getElementById("a_namee").value;
                    var a_tell=document.getElementById("a_tell").value;
                var a_id=document.getElementById("a_id").value;
                    $.ajax({
                        url:"${pageContext.request.contextPath}/UpdateAddressServlet.do",
                        data:{"a_namee":a_namee,"a_addd":a_addd,"a_tell":a_tell,"a_id":a_id},
                        type:"post",
                        dataType:"json",
                        success:function(data){
                            alert("修改成功");
                            jQuery.post("${pageContext.request.contextPath}/FindAddressServlet.do",{"u_id":${sessionScope.user.U_ID}},function (data) {
                                var tr="";
                                tr+="<table class='table table-hover'>";
                                tr+="<tr>";
                                tr+="<td>地址编号</td>"
                                tr+="<td>收货人</td>";
                                tr+=" <td>收货地址</td>";
                                tr+=" <td>手机号</td>";
                                tr+=" <td>操作</td>";
                                tr+="</tr>";
                                tr+="<tbody>";
                                jQuery.each(data,function (i,item) {
                                    tr+="<tr>";
                                    tr+="<td>";
                                    tr+=item.A_ID;
                                    tr+="</td>";
                                    tr+="<td>";
                                    tr+=item.A_NAME;
                                    tr+="</td>";
                                    tr+="<td>";
                                    tr+=item.A_ADD;
                                    tr+="</td>";
                                    tr+="<td>";
                                    tr+=item.A_TEL;
                                    tr+="</td>";
                                    tr+="<td>";
                                    tr+="<button type='button' class='btn btn-danger' name='a_id' onclick='return PoppLayer(this)'>修改</button>";
                                    tr+="<button type='button' class='btn btn-danger' name='a_id' onclick='doDelete(this,"+item.A_ID+")'>删除</button>";
                                    tr+="</td>";
                                    tr+="</tr>";
                                });
                                tr+="</tbody>";
                                tr+=" </table>";
                                jQuery("#tt").html(tr);
                            },"JSON");
                        },
                        error:function(){
                            alert("修改失败");
                        }
                    });
                }
            )
        }


        //显示已保存的收货地址
        if(id=="#container-dizhi")
        {
            jQuery.post("${pageContext.request.contextPath}/FindAddressServlet.do",{"u_id":${sessionScope.user.U_ID}},function (data) {
                var tr="";
                tr+="<table class='table table-hover'>";
                tr+="<tr>";
                tr+="<td>地址编号</td>"
                tr+="<td>收货人</td>";
                tr+=" <td>收货地址</td>";
                tr+=" <td>手机号</td>";
                tr+=" <td>操作</td>";
                tr+="</tr>";
                tr+="<tbody>";
                jQuery.each(data,function (i,item) {
                    tr+="<tr>";
                    tr+="<td>";
                    tr+=item.A_ID;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.A_NAME;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.A_ADD;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.A_TEL;
                    tr+="</td>";
                    tr+="<td>";
                    tr+="<button type='button' class='btn btn-danger' name='a_id' " +
                        "onclick=\"return PoppLayer(this,'"+item.A_ID+"','"+item.A_NAME+"','"+item.A_ADD+"','"+item.A_TEL+"')\">修改</button>";
                    tr+="<button type='button' class='btn btn-danger' name='a_id' onclick='doDelete(this,"+item.A_ID+")'>删除</button>";
                    tr+="</td>";
                    tr+="</tr>";
                });
                tr+="</tbody>";
                tr+=" </table>";
                jQuery("#tt").html(tr);
            },"JSON");
        }
    });
    function getPage(f)
    {
        jQuery.post("${pageContext.request.contextPath}/AjaxtwoServlet.do",{"flag":f},function (data) {
            var tr="";
            jQuery.each(data,function (i,item) {
                tr+="<tr>";
                tr+="<td>";
                var date=new Date(item.O_DATE);
                tr+=date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
                tr+="</td>";
                tr+="<td>";
                tr+=item.O_PRICE;
                tr+="</td>";
                tr+="</tr>";
            });
            jQuery("#ttt").html(tr);
        },"JSON");
    }
    //删除收货地址
    function doDelete(obj,n) {
        $.ajax({
            url:"${pageContext.request.contextPath}/DeleteAddressServlet.do",
            data:{"a_id":n},
            type:"post",
            dataType:"json",
            success:function(data){
                alert("删除成功");
                jQuery.post("${pageContext.request.contextPath}/FindAddressServlet.do",{"u_id":${sessionScope.user.U_ID}},function (data) {
                    var tr="";
                    tr+="<table class='table table-hover'>";
                    tr+="<tr>";
                    tr+="<td>地址编号</td>"
                    tr+="<td>收货人</td>";
                    tr+=" <td>收货地址</td>";
                    tr+=" <td>手机号</td>";
                    tr+=" <td>操作</td>";
                    tr+="</tr>";
                    tr+="<tbody>";
                    jQuery.each(data,function (i,item) {
                        tr+="<tr>";
                        tr+="<td>";
                        tr+=item.A_ID;
                        tr+="</td>";
                        tr+="<td>";
                        tr+=item.A_NAME;
                        tr+="</td>";
                        tr+="<td>";
                        tr+=item.A_ADD;
                        tr+="</td>";
                        tr+="<td>";
                        tr+=item.A_TEL;
                        tr+="</td>";
                        tr+="<td>";
                        tr+="<button type='button' class='btn btn-danger' name='a_id' " +
                            "onclick=\"return PoppLayer(this,'"+item.A_ID+"','"+item.A_NAME+"','"+item.A_ADD+"','"+item.A_TEL+"')\">修改</button>";
                        tr+="<button type='button' class='btn btn-danger' name='a_id' onclick='doDelete(this,"+item.A_ID+")'>删除</button>";
                        tr+="</td>";
                        tr+="</tr>";
                    });
                    tr+="</tbody>";
                    tr+=" </table>";
                    jQuery("#tt").html(tr);
                },"JSON");
            },
            error:function(){
                alert("删除失败");
            }
        });
    }
</script>
<script language="javascript" type="text/javascript">
    function address(num,v_sel){
        var x_p =  document.getElementsByClassName("sel_p")[0].value;
        var x_c =  document.getElementsByClassName("sel_c")[0].value;
        if(x_p && x_c){
            document.getElementById("a_add").value = x_p + x_c;
        }
    }
</script>
<script type="text/javascript">
    var citys=[];
    citys["山东省"]=["济南市","青岛市","滨州市"];
    citys["四川省"]=["成都市","雅安市","达州市"];
    citys["湖北省"]=["武汉市","三峡市"];
    citys["江苏省"]=["南京市","扬州市","镇江市"];
    function addPro(){
        var pro = document.getElementById("pro");
        //for in 获取每一个下标
        for(var p in citys){
            //根据获取的下标构建一个下拉选项
            var op=new Option(p,p);
            //把option添加到下拉列表中
            pro.add(op);
        }
    }
    function addCity(){
        //获取省的下拉列表中选择的内容
        var pro = document.getElementById("pro").value;
        //获取该省对应的城市列表
        var cs = citys[pro];
        var city=document.getElementById("city");
        //清除已添加的所有内容
        city.options.length=0;
        for(var c in cs){
            var op = new Option(cs[c],cs[c]);
            city.add(op);
        }
    }
    window.onload=addPro();
</script>

<script type="text/javascript">
    var citys=[];
    citys["山东省"]=["济南市","青岛市","滨州市"];
    citys["四川省"]=["成都市","雅安市","达州市"];
    citys["湖北省"]=["武汉市","三峡市"];
    citys["江苏省"]=["南京市","扬州市","镇江市"];
    function addProo(){
        var proo = document.getElementById("proo");
        //for in 获取每一个下标
        for(var p in citys){
            //根据获取的下标构建一个下拉选项
            var op=new Option(p,p);
            //把option添加到下拉列表中
            proo.add(op);
        }
    }
    function addCityy(){
        //获取省的下拉列表中选择的内容
        var proo = document.getElementById("proo").value;
        //获取该省对应的城市列表
        var cs = citys[proo];
        var cityy=document.getElementById("cityy");
        //清除已添加的所有内容
        cityy.options.length=0;
        for(var c in cs){
            var op = new Option(cs[c],cs[c]);
            cityy.add(op);
        }
    }
    window.onload=addProo();
</script>
<script language="javascript" type="text/javascript">
    function addresss(num,v_sel){
        var x_pp =  document.getElementsByClassName("sel_pp")[0].value;
        var x_cc =  document.getElementsByClassName("sel_cc")[0].value;
        if(x_pp && x_cc){
            document.getElementById("a_addd").value = x_pp + x_cc;
        }
    }
</script>

<script>
    function PoppLayer(obj,a,b,c,d) {
        lightboxx.style.display = popp.style.display = obj ? 'block' : 'none';
        jQuery("#a_id").val(a);
        jQuery("#a_namee").val(b);
        jQuery("#a_addd").val(c);
        jQuery("#a_tell").val(d);
        return false;
    }
</script>

<script type="text/javascript">
    var btn3=document.getElementById("btn3");
    var btn4=document.getElementById("btn4");
    var imgBox3=document.getElementById("imgBox3");
    var imgBox4=document.getElementById("imgBox4");
    function xiaoshi(){
        btn3.style.background="#f8f6f4";
        btn4.style.background="#f8f6f4";
        btn3.style.color="#666";
        btn4.style.color="#666";
        imgBox3.style.display="none";
        imgBox4.style.display="none";
    }
    btn3.onclick=function(){
        xiaoshi();
        btn3.style.background="white";
        btn3.style.color="red";
        imgBox3.style.display="flex";
    }
    btn4.onclick=function(){
        xiaoshi();
        btn4.style.background="white";
        btn4.style.color="red";
        imgBox4.style.display="flex";
    }
</script>
</html>